library(plyr)
library(stringr)
library(magrittr)
library(tidyverse)
library(broom)
library(readxl)


rm(list=ls())
home = 'C:/Users/jdt34/Dropbox/VNA_Responsiveness/Short Article/JOP-dataverse/'


dv_survey = paste0(home, 'Data/survey-outcomes.xlsx') %>%
  read_xlsx %>%
  mutate(Treatment=factor(x=Treatment, 
                          levels=c('Control',
                                   'Citizen',
                                   'Firm')),
         Missing=as.integer(is.na(Q1))) %>%
  subset(!is.na(Treatment))


dv_pooled = paste0(home, 'Data/pooled-outcomes.xlsx') %>%
  read_xlsx %>%
  mutate(Treatment=factor(x=Treatment, 
                          levels=c('Control',
                                   'Citizen',
                                   'Firm'))) %>%
  subset(!is.na(Treatment))

dv_caucus = paste0(home, 'Data/caucus-outcomes.xlsx') %>%
  read_xlsx %>%
  mutate(Treatment=factor(x=Treatment, 
                          levels=c('Control',
                                   'Citizen',
                                   'Firm'))) %>%
  subset(!is.na(Treatment))

dv_query = paste0(home, 'Data/query-outcomes.xlsx') %>%
  read_xlsx %>%
  mutate(Treatment=factor(x=Treatment, 
                          levels=c('Control',
                                   'Citizen',
                                   'Firm'))) %>%
  subset(!is.na(Treatment))

dv_floor = paste0(home, 'Data/floor-outcomes.xlsx') %>%
  read_xlsx %>%
  mutate(Treatment=factor(x=Treatment, 
                          levels=c('Control',
                                   'Citizen',
                                   'Firm'))) %>%
  subset(!is.na(Treatment))


paste0(home, 'Code/data-prep-real-analysis.R') %>%
  source


experimental.results = real.analysis()


paste0(home, 'Data/experimental-analyses.Rds') %>%
  saveRDS(object=experimental.results, file=.)
